﻿using JoinParty.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Data.Models.JoinParty;

namespace JoinParty.Template
{
    public partial class TJoinStep19ForHtml : TemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
            System.IO.StringWriter SW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            palWord.RenderControl(HTW);
            var html = SW.ToString();
            Response.Clear();
            Response.Write(html);
            Response.End();
        }
        public void LoadData()
        {
            litUserName.Text = PartyJoinApplycation.UserName;
            litUserName2.Text = PartyJoinApplycation.UserName;
            litGender.Text = PartyOrgMember.Gender == "0" ? "男" : "女";
            litNation.Text = PartyOrgMember.Nation;
            litBirthday.Text = Convert.ToDateTime(PartyOrgMember.Birthday).ToString("yyyy-MM-dd");
            litNativePlace.Text = PartyOrgMember.NativePlace;
            litBirthplace.Text = PartyOrgMember.Birthplace;
            litEducational.Text = PartyOrgMember.Educational;
            litTitle.Text = PartyOrgMember.Title;

            var stand = DB.PartyJoinLinkExamples.Where(s => s.AppllicationID == PartyJoinApplycation.AppllicationID && s.Status == 1 && s.CurrentStepID == "JoinStep8")
                .OrderByDescending(s => s.CreateTime).FirstOrDefault();
            string activistsId = partyJoinPartyActivists.GetActivistsIDByStandID(stand.StandID);
            var oModel = DB.partyJoinPartyActivistss.Find(activistsId);
            litWorkUnit.Text = oModel.PresentOccupation;
            litAddress.Text = PartyOrgMember.Address;

            litIdentityCard.Text = PartyOrgMember.IdentityCard;
            litExpertise.Text = PartyOrgMember.Expertise;


            var resume = DB.PartyJoinProbationaryResumes.Where(r => r.ActivistsID == activistsId);
            if (resume != null)
            {
                var resume1 = resume.Where(r => r.OrderNo == 0).FirstOrDefault();
                if (resume1 != null)
                {
                    LiteralOne1.Text = resume1.StartTime;
                    LiteralOne2.Text = resume1.EndTime;
                    LiteralOne3.Text = resume1.Where;
                    LiteralOne4.Text = resume1.Witness;
                    var resume2 = resume.Where(r => r.OrderNo == 1).FirstOrDefault();
                    if (resume2 != null)
                    {
                        LiteralTwo1.Text = resume2.StartTime;
                        LiteralTwo2.Text = resume2.EndTime;
                        LiteralTwo3.Text = resume2.Where;
                        LiteralTwo4.Text = resume2.Witness;
                        var resume3 = resume.Where(r => r.OrderNo == 2).FirstOrDefault();
                        if (resume3 != null)
                        {
                            LiteralThree1.Text = resume3.StartTime;
                            LiteralThree2.Text = resume3.EndTime;
                            LiteralThree3.Text = resume3.Where;
                            LiteralThree4.Text = resume3.Witness;
                            var resume4 = resume.Where(r => r.OrderNo == 3).FirstOrDefault();
                            if (resume4 != null)
                            {
                                LiteralFour1.Text = resume4.StartTime;
                                LiteralFour2.Text = resume4.EndTime;
                                LiteralFour3.Text = resume4.Where;
                                LiteralFour4.Text = resume4.Witness;
                                var resume5 = resume.Where(r => r.OrderNo == 4).FirstOrDefault();
                                if (resume5 != null)
                                {
                                    LiteralFive1.Text = resume5.StartTime;
                                    LiteralFive2.Text = resume5.EndTime;
                                    LiteralFive3.Text = resume5.Where;
                                    LiteralFive4.Text = resume5.Witness;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}